package com.cbw.firegame.order.task;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cbw.common.vo.OrderEntity;
import com.cbw.firegame.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;
@Slf4j
@Component
public class SchedureTask {

    @Autowired
    OrderService orderService;

    @Scheduled(cron = "0 0 0 * * ?")
    public void update(){

        List<OrderEntity> status = orderService.list(new QueryWrapper<OrderEntity>().eq("status", 0));
        if (status!=null &&status.size()>0){
            status.forEach(item->{
                item.setStatus(2);
                orderService.updateById(item);
            });
        }
      log.info("执行了定时任务");
    }



}
